﻿using SharpCompress.Archives;
using SharpCompress.Common;
using SharpCompress.Readers;
using SharpCompress.Writers;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace CommonLibrary.Utils
{
    public class CompressUtils
    {
        //public static bool CompressGZip(string srcFolder, string dstFile)
        //{
        //    if (!Directory.Exists(srcFolder))
        //        throw new DirectoryNotFoundException(srcFolder);

        //    if (File.Exists(dstFile))
        //        File.Delete(dstFile);

        //    using Stream stream = File.Create(dstFile);
        //    using IWriter writer = WriterFactory.Open(stream, ArchiveType.Zip, new WriterOptions(CompressionType.BZip2)
        //    {
        //        LeaveStreamOpen = true
        //    });
        //    var archiveWriter = ArchiveFactory.Open(stream, new ReaderOptions { LeaveStreamOpen = true });//Create(ArchiveType.Zip);
        //    archiveWriter.WriteToDirectory(srcFolder, new ExtractionOptions { Overwrite = true });
        //    //archiveWriter.AddAllFromDirectory(srcFolder, "*", SearchOption.AllDirectories);

        //    //using IWriter writer = WriterFactory.Open(stream, ArchiveType.Zip, new WriterOptions(CompressionType.BZip2)
        //    //{
        //    //    LeaveStreamOpen = true
        //    //});
        //    //writer.WriteAll(srcFolder, "*", SearchOption.AllDirectories);

        //    return true;
        //}

    }
}